package main.java.indi.zyj.coderecord;

public class Fib {

    public int fib(int n) {

        if (n == 0) {
            return 0;
        }
        if (n == 1) {
            return 1;
        }

        int res = 0, a = 0, b = 1;
        for (int i = 2; i < n; i++) {
            res = a + b;
            a = b;
            b = res;
        }

        return res;
    }

}
